//
//  MLBaseTableViewController.swift
//  weibo
//
//  Created by manmanlang on 16/6/22.
//  Copyright © 2016年 manmanlang. All rights reserved.
//

import UIKit

class MLBaseTableViewController: UITableViewController,MLVisitorViewDelegate {
    
    var isLogin:Bool = MLUserAccountTool.sharedTool.isLogin
    
    var visitor:MLVisitorView?
    
    override func loadView() {
        
        if isLogin {
            super.loadView()
        }else {
            visitor = MLVisitorView()
            visitor?.startAnimation()
            visitor?.delegate = self
            setupNav()
            
            view = visitor
        }
    }
    
    private func setupNav() {
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(self.leftBarButtonClick))
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(self.rightBarButtonClick))
    }
    
    func leftBarButtonClick() {
        let oauthVC = MLOAuthController()
        let naVC = UINavigationController(rootViewController: oauthVC)
        presentViewController(naVC, animated: true, completion: nil)
        printLog("注册")
    }
    func rightBarButtonClick() {
        leftBarButtonClick()
        printLog("登录")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

}
